Queues are commonly used in data processing systems. A large number of queues are widely used by system kernels to control the reusable hardware and/or software resources. For example, the schedulers of operating systems usually use queues to receive user requests, and dispatch jobs according to the queues.
Generally, a queue includes a plurality of entries (or elements), in which each element is a unit of the queue and usually contains user data. There are two broad categories of queues based on their implementation: arrays and linked lists. Elements in an array are usually located next to each other, while elements in a linked list contain the addresses of other elements. Array queues are easy to manage but generally have a maximum number of possible entries. Linked list queues require a slightly more complicated management scheme, but their size is bounded only by available storage space.
A queue usually has two kinds of clients, producers and consumers. A producer generates data and puts them into the queue, while a consumer retrieves data from a queue. Client accesses of a queue include inserting an element, deleting (or removing) an element, searching for an element and testing whether a queue is empty. Creating and destroying the queue itself can also be considered forms of client access.
Multiprocessing (MP) allows two or more processors to execute separate instruction streams in relation to a shared main storage simultaneously. MP has been recognized as presenting special problems for queue access. For example, the integrity of a queue may be affected if one processor tries to insert an element before another processor completes its insertion.
In the past, there were generally two ways to solve this problem. One solution uses locks to guarantee exclusive access to the queue by one client. The other solution limits client access points (where clients can insert/delete elements) and provides operations to set and swap conditions atomically. Both approaches limit the number of clients that can access the queue simultaneously, resulting in poor efficiency of existing queuing methods in MP environments.
U.S. Pat. No. 4,482,956, entitled “Parallel Queuing Methods,” issued Nov. 13, 1984, discloses a way to allow multiple insertion accesses to a queue simultaneously. However, clients have to serialize operations to search or retrieve data from a queue: i.e., only one processor can search or retrieve data at a time. The '956 patent can only be applied to simple linked lists with fix access points of insertion and deletion.
The previous solutions (including the '956 patent) do not solve the problem. They fail to separate the structure of the queue from the data the queue contains. The previous solutions use either locks or doors (access points) to prevent multiple accesses to the queue. Although many processors can compete for a door, only one processor can access the door at a time.
U.S. Pat. No. 6,412,034, entitled “Transaction-Based Locking Approach,” issued Jun. 25, 2002, teaches a system and method for locking resources in an environment. Rather than limiting resources to individual processes, the '034 patent describes how related processes can be granted simultaneous access to a resource. Upon receiving a request to access a resource, a centralized lock manager LM checks to see if the resource is currently locked. If so, the lock manager LM determines the transaction with which a process is associated. If the process is associated with the same transaction as the process that has locked the resource, then the lock manager LM allows the second process access to the resource. Otherwise, the lock manager LM denies the second process access to the resource.
The '034 patent also fails to solve the problem, in that it requires a lock manager. The lock manager LM acts as a single point of access for the system, in that before any process can use a resource, the process has to be granted access by the lock manager LM. All requests for resources have to funnel through the lock manager. If the lock manager is busy servicing one request, other requests have to wait, which can be inefficient.
Accordingly, a need remains for a queueing system that allows for efficient queue use and management in an MP environment with multiple simultaneous queue accesses.